package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.BaseOwnerInfo;
import com.softer.wxzj.entity.HouseAndOwner;
import com.softer.wxzj.entity.TransReq;
import com.softer.wxzj.service.TransReqService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * RefReqController class
 *
 * @author wxr
 * @date 2019/7/1
 */
@RestController
@RequestMapping("/transReq")
@Slf4j
public class TransReqController {
    /**
     * 过户业主
     */
    @Autowired
    TransReqService transReqService;
    @RequestMapping("/add")
    @LogRecord(description = "业主过户", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.INSERT)
    public CommonResult add(@RequestBody List<BaseOwnerInfo> list) {
        return transReqService.ownerTransferList(list);
    }

    /**
     * 过户查询
     * @param page
     * @param transReq
     * @return
     */
    @RequestMapping("/getList")
    @LogRecord(description = "业主过户", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.SELECT)
    public PageInfo<TransReq> getList(Page page, TransReq transReq) {
        return transReqService.getList(page,transReq);
    }
    /**
     * 过户查询
     * @param id
     * @return
     */
    @RequestMapping("/selectOldAndNewOwner")
    @LogRecord(description = "业主过户时新旧业主信息", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.SELECT)
    public List<List<BaseOwnerInfo>> selectOldAndNewOwner(String id) {
        return transReqService.selectOldAndNewOwner(id);
    }
    /**
     * 过户审核列表
     * @param houseAndOwner
     * @param page
     * @return
     */
    @RequestMapping("/selecthouseFlowState")
    @LogRecord(description = "过户审核列表", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.SELECT)
    public PageInfo<HouseAndOwner> selecthouseFlowState(Page page, HouseAndOwner houseAndOwner) {
    return transReqService.selecthouseFlowState(page, houseAndOwner);
    }
    /**
     * 过户审核
     * @param id
     * @param opinion
     * @param mark
     * @return
     */
    @RequestMapping("/addAudit")
    @LogRecord(description = "过户审核", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.SELECT)
    public CommonResult addAudit(String id,String opinion,String mark) {
        return transReqService.addAudit(id, opinion, mark);
    }

    @RequestMapping("/submitAudit")
    @LogRecord(description = "业主过户提交审核", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.UPDATE)
    public CommonResult submitAudit(@RequestParam("id") String id, String arcType) {
        return transReqService.submitAudit(id,arcType);
    }

    /**
     * 申请撤销
     * @param id
     * @return
     */
    @RequestMapping("/applicationRevocation")
    @LogRecord(description = "申请撤销", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.UPDATE)
    public CommonResult applicationRevocation(String id){
        return transReqService.applicationRevocation(id);
    }
    /**
     * 修改新业主
     * @param baseOwnerInfos
     * @return
     */
    @RequestMapping("/updateOwnerNo")
    @LogRecord(description = "修改新业主", operationUnit = LogOperationUnit.TRANS_REQ, operationType = LogOperationType.UPDATE)
    public CommonResult updateOwnerNo(@RequestBody List<BaseOwnerInfo> baseOwnerInfos ){
        return transReqService.updateOwnerNo(baseOwnerInfos);
    }


}
